Set the object handle?

Hi!

I want to set the startvalue of the object for-loop to a specific value. Can it be possible? My idea was like this example-code:

 

//This while-loop jumps over the first chapter
    gobj_SSF = first(gobj_SSF);        //make sure, that the first line is pointed to
    gobj_SSF = next(gobj_SSF);        //go one object further
    while(level(gobj_SSF) > 1)
    {
        gobj_SSF = next(gobj_SSF);
        gobj_tmp = gobj_SSF;
    }

//This for-loop iterates over alle objects and writes in specific .txt-file
    for gobj_SSF in gmod_SSF do
    {
        //Debug
        print "for-loop" identifier(gobj_SSF) "\n";
        gobj_SSF = gobj_tmp;
        //Debug
        print "for-loop" identifier(gobj_SSF) "\n";
        
        ident = identifier(gobj_SSF) "$$";
        statusHarmonisierung = gobj_SSF."Status Harmonisierung""" "$$";
        statusHarmonisierung = gobj_SSF."Status Harmonisierung""" "$$";
        objectHeading = gobj_SSF."Object Heading""" "$$";
        objectText = gobj_SSF."Object Text""" "$$";
        typ = gobj_SSF."Typ""" "$$";
        aenderungsStatus = gobj_SSF."Änderungsstatus""" "$$";
        aenderungsBemerkung = gobj_SSF."Änderungsbemerkung""";
        objectLevel = level(gobj_SSF);
        
        concatenatedAttributeLine = "§§" ident statusHarmonisierung objectHeading objectText typ aenderungsStatus aenderungsBemerkung "&&" "\n\n\n";    //§§ = startsymbol, $$ = Trennung von Attributen, && = endsymbol
        output << concatenatedAttributeLine;    //Write output-String in .txt-file
    }

 

 

The problem is, that the object handle will be reset. Can anyone help me?

 


tobi_mehrl - Mon Dec 15 03:30:43 EST 2014

Re: Set the object handle?
Mathias Mamsch - Mon Dec 15 04:38:59 EST 2014

You cannot do that in a "for ... in ... do" loop. But of cause you can check for a flag:

bLoop = false; 
for gobj_SSF in gmod_SSF do
    {
        // Start looping after reaching gobj_tmp  
        if (gobj_SFF == gobj_tmp) bLoop = true;   
        if (!bLoop) continue;
        ...

For more complicated situations you might want to put the objects in a skip list first, maybe in multiple looping passes, and then iterate over the skip list. Regards, Mathias

Re: Set the object handle?
tobi_mehrl - Mon Dec 15 05:36:59 EST 2014

Thanks for your answer.

Is there are a option to iterate only over one specific chapter?

In my Module I have 3 chapter, from which chapter I only need chapter 2...

Re: Set the object handle?
llandale - Mon Dec 15 14:25:48 EST 2014

Mathias Mamsch - Mon Dec 15 04:38:59 EST 2014

You cannot do that in a "for ... in ... do" loop. But of cause you can check for a flag:

bLoop = false; 
for gobj_SSF in gmod_SSF do
    {
        // Start looping after reaching gobj_tmp  
        if (gobj_SFF == gobj_tmp) bLoop = true;   
        if (!bLoop) continue;
        ...

For more complicated situations you might want to put the objects in a skip list first, maybe in multiple looping passes, and then iterate over the skip list. Regards, Mathias

.. and stop when you get to chapter 3.  At top:

  • if (bLoop and level(gobj_SSF) == 1) then break

Or, if you KNOW it is chapter "2", do this instead:

  • if (number(gobj_SSF)[0:1] != "2.") then continue

-Louie